//
//  YXRunStaticBarTableViewCell.m
//  fitness
//
//  Created by yunxiang on 2017/8/30.
//  Copyright © 2017年 YunXiang. All rights reserved.
//

#import "YXRunStaticBarTableViewCell.h"

@interface YXRunStaticBarTableViewCell ()


@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property(nonatomic,strong)UILabel *bglable;

@end

@implementation YXRunStaticBarTableViewCell

- (void)resetFrameWithValue:(DISAProfitList *)model maxValue:(CGFloat)maxValue
{
    
    CGFloat  value = [model.earning floatValue];
    self.timeLabel.text = model.area_name;
    self.timeLabel.textColor = [UIColor colorWithHexString:@"#4A4A4A"];
    CGRect frame;
    frame.origin.x = self.BGVIew.left;
    frame.origin.y = self.BGVIew.top;
    CGFloat temp;
    if (value != 0) {
        temp = (CGFloat)( maxValue- value )/maxValue;
    }else{
        temp = 1;
    }
    frame.size.height = self.barView.height*temp;
    frame.size.width = self.BGVIew.width;
    self.BGVIew.frame = frame;
    
    if ([self.numberLB.text isEqualToString:@"00"]) {
//        self.numberLB.frame =CGRectMake(self.BGVIew.left, frame.size.height, self.barView.height*temp, 20);
        
//        self.numberLB.centerX =self.BGVIew.centerX+5;
        
        [self.numberLB mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.offset(0);
            make.height.offset(20);
            make.bottom.mas_equalTo(self.BGVIew.mas_bottom).offset(0);
        }];
        
        
        [self.bglable mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(0);
            make.height.offset(1);
            make.width.offset(KWIDTH);
            make.bottom.mas_equalTo(self.barView.mas_bottom).offset(0);
        }];
        
    }
    

    
    self.numberLB.text = [NSString stringWithFormat:@"%@",model.earning];
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    self.numberLB.textAlignment = NSTextAlignmentCenter;
    self.numberLB.font = [UIFont systemFontOfSize:9];
    self.numberLB.textColor = K999999;
   self.bglable = [[UILabel alloc]init];
     self.bglable.backgroundColor = [UIColor colorWithHexString:@"#70BE68"];
    [self.contentView addSubview: self.bglable];
    CGFloat dfdf = -24;
    
    if (IPHONE_X) {
        dfdf = -40;
    }
//    [self.bglable mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.bottom.offset(dfdf);
//        make.height.offset(1);
//        make.width.offset(KWIDTH);
//        make.left.offset(0);
//    }];
    self.timeLabel.width = KWIDTH/6;
    self.timeLabel.adjustsFontSizeToFitWidth = YES;
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
